<script type="text/javascript">
function getProvince() {
	$('select[id="provinceId"]').html('');
	provinceObj.each(function (key,value,index) {
		$("select[id='provinceId']").append('<option value="'+key+'" >'+value+'</option>');
	});
	var province_id = $('select[id="provinceId"]').val();
	changeProvince(province_id);
}

function changeProvince(id) {
	var provinceIdFormat = id+"_";
	$('select[id="cityId"]').html('');
	provinceCityObj.each(function (key,value,index) {
		if(key.startWith(provinceIdFormat)) {
			var cityId = key.substring(provinceIdFormat.length);
			$("select[id='cityId']").append('<option value="'+cityId+'" >'+value+'</option>');
		}
	});
	$('select[id="disId"]').html('');
	var city_id = $('select[id="cityId"]').val();
	var cityIdFormat = city_id+"_";
	cityDistrictObj.each(function (key,value,index) {
		if(key.startWith(cityIdFormat)) {
			var distId = key.substring(cityIdFormat.length);
			$("select[id='disId']").append('<option value="'+distId+'" >'+value+'</option>');
		}
	});
}

function changeCity(id){
	$('select[id="disId"]').html('');
	var cityIdFormat = id+"_";
	cityDistrictObj.each(function (key,value,index) {
		if(key.startWith(cityIdFormat)) {
			var distId = key.substring(cityIdFormat.length);
			$("select[id='disId']").append('<option value="'+distId+'" >'+value+'</option>');
		}
	});
}

   /* 
	* url 目标url 
	* arg 需要替换的参数名称 
	* arg_val 替换后的参数的值 
	* return url 参数替换后的url 
	*/ 
	function changeURLArg(url,arg,arg_val){ 
    	var pattern=arg+'=([^&]*)'; 
    	var replaceText=arg+'='+arg_val; 
    	if(url.match(pattern)){ 
        	var tmp='/('+ arg+'=)([^&]*)/gi'; 
        	tmp=url.replace(eval(tmp),replaceText); 
        	return tmp; 
    	}else{ 
        	if(url.match('[\?]')){ 
            	return url+'&'+replaceText; 
        	}else{ 
            	return url+'?'+replaceText; 
        	} 
    	} 
    	return url+'\n'+arg+'\n'+arg_val; 
	} 

var doorHmtl = '<fieldset style="border:0px">\
				<p>\
					<label></label>\
					<input type="text" name="door" value="" style="width: 150px;margin-left: 130px;" class="textInput">\
					<a id="addDoorChild" href="#" onclick="deleteDoor(this)" style="margin-left:10px;" class="btnDel" title="添加房间">\
					 添加房间\
					</a>\
				</p>\
			</fieldset>';
function addDoor(){
	$('#add_door_field').after($(doorHmtl));
}

function deleteDoor(that){
	$(that).closest('fieldset').remove();
}
</script>

<div class="pageContent">
	<form method="post" action="${basePath }/admin/house/save.do?navTabId=saveHouse" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxAdd);">
		<div class="pageFormContent" layoutH="86">
			<fieldset>
			<legend>地址信息</legend>
			<fieldset style="border:0px">
			<p>
				<label>省：</label>
				<select id="provinceId" name="provinceId" onchange="changeProvince(this.value);" class="required" style="width: 75px;" >
					<script>
						getProvince();
					</script>
				</select>
			</p>
			</fieldset>
			
			<fieldset style="border:0px">
			<p>
				<label>市：</label>
				<select id="cityId" name="cityId" onchange="changeCity(this.value)" class="required" style="width: 75px;" >
					<option value="3" selected>上海市</option>
				</select>
			</p>
			</fieldset>
			
			<fieldset style="border:0px">
			<p>
				<label>区：</label>
				<select id="disId" name="dist" class="required" style="width: 75px;" >
					<option value="" selected></option>
				</select>
			</p>
			</fieldset>
			
			<fieldset style="border:0px">
				<p>
					<label>房源名称：</label>
					<input type="text" name="name" value="" class="required" style="width: 150px;" />
				</p>
			</fieldset>
			
			<fieldset style="border:0px">
				<p>
					<label>详细地址：</label>
					<input type="text" name="street" value="" class="required" style="width: 150px;" />
				</p>
			</fieldset>
			
			<fieldset style="border:0px;" >
				<p>
					<label>小区名：</label>
					<input type="text" name="buildingName" value="" class="required" style="width: 150px;" />
				</p>
			</fieldset>
			
			<fieldset style="border:0px">
				<p>
					<label>楼栋：</label>
					<input type="text" name="buildingNo" value="" style="width: 150px;" />
				</p>
			</fieldset>
			
			<fieldset style="border:0px">
				<p>
					<label>单元：</label>
					<input type="text" name="uint" value="" style="width: 150px;" />
				</p>
			</fieldset>
			
			<fieldset style="border:0px">
				<p>
					<label>室：</label>
					<input type="text" name="roomNo" value="" style="width: 150px;" />
				</p>
			</fieldset>
			
			<fieldset style="border:0px" id="add_door_field">
				<p>
					<label>房间号：</label>
					<input type="text" name="door" value="" style="width: 150px;" />
					<a id="add_door" href="#" onclick="addDoor()" style="margin-left:10px;" class="btnAdd" title="添加房间">
					 添加房间
					</a>
				</p>
			</fieldset>
			
			
			
			
			
			<fieldset>
			<legend>联系信息</legend>
			<fieldset style="border:0px">
				<p>
					<label>房东手机号：</label>
					<input type="text" name="landlordMobile" value="" class="mobile" style="width: 150px;" />
				</p>
			</fieldset>
			</fieldset>
		</div>
		<div class="formBar">
			<ul>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">
								保存
							</button>
						</div>
					</div>
				</li>
				<li>
					<div class="button">
						<div class="buttonContent">
							<button type="button" class="close">
								取消
							</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</form>
</div>
